package hu.myai.indicators;

import hu.myai.api.indicators.AbstractIndicator;
import hu.myai.model.IndicatorVO;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Indicator is the first level of stock evaluation. An Indicator does a math
 * calculation and populates its double result to all registered objects
 * (indicator or trigger). Indicator registers all necessary resources, however
 * it cannot attache itself to a tick source. You have to do it by yourself. It
 * is not a problem if the trigger constructs the indicator.
 *
 * @author bozbalint
 *
 */
public class DummyIndicator extends AbstractIndicator {

    /**
     * The object is used when logging debug,errors,warnings and info.
     * */
    private final Logger log = LoggerFactory.getLogger(this.getClass());

    /**
     * Constructor
     */
    public DummyIndicator(Double parameter) {
        super(parameter);
    }

    /**
     * Here can be a reference id for use the register indicator value in the calculation
     * method. eg: private String dummyID;
     * */


    @Override
    public void init() {
        /**
         * register() is a method for initialize indicators. Framework will
         * configure the indicator that provides the inputs to the trigger. eg:
         * xxxXXXxxID = register(new XXXXXIndicator(parameter));
         * */
    }

    @Override
    protected IndicatorVO indicatorCalculation() {

        /**
         * - parameter: is the only pre-registered attribute of the indicator -
         * - lastTick: is the last received tick<br>
         * - tickHistory: contains all available ticks. the last is the latest
         * arrived<br>
         * - indicatorMap: contains all received indicator values<br>
         * - indicatorNameList: contains all registered indicator names. You can
         * use it at indicatorMap. The indicator name order is the same as how
         * you registered the indicators in the constructor.
         * */

        IndicatorVO indicatorVO = new IndicatorVO();
        indicatorVO.setValue(lastTick.getClose() * parameter);
        indicatorVO.setDate(lastTick.getTime());

        log.debug("IndivatorVO: " + indicatorVO.toString());

        return indicatorVO;
    }
}
